package de.gwtprime.client;

import com.google.web.bindery.requestfactory.shared.Receiver;
import com.google.web.bindery.requestfactory.shared.ServerFailure;


/**
 * Receiver that shows notifications on success and failure
 * @author jan
 *
 * @param <V>
 */
public class PrimeReceiver<V> extends Receiver<V> {

	private ClientFactory clientFactory;
	
	public PrimeReceiver(ClientFactory clientFactory){
		this.clientFactory = clientFactory;
	}
	
	/**
	 * Called if the ajax call succeeded
	 */
	@Override
	public void onSuccess(V response) {
		clientFactory.getNotificationCenter().showMessage("Success");
	}
	
	/**
	 * Called if the ajax call failed.
	 */
	@Override
	public void onFailure(ServerFailure error) {
		
		clientFactory.getNotificationCenter().showMessage(error.getMessage());
		
		super.onFailure(error);
	}

}
